from collections import OrderedDict
a2mod = OrderedDict({
    2:1,
    3:2,
    5:4,
    7:4,
    11:0,
    13:10,
    17:0,
    19:18,
    23:15,
    29:16,
    31:27,
    37:22,
    41:1,
    43:11,
    47:5
  })

def is_conditional(num):
  for a, mod in a2mod.items():
    if num % a != mod:
      return False
  
  return True

def find_min_condi():

  min_num = 11 * 17

  def find(num):
    if is_conditional(num) and num <= min_num:
      min_num = num
      return

    find(num * 11)
    find(num * 17)

  find(11 * 17)

  print(min_num)

find_min_condi()



